<extend name="Index:base" />
<block name="title"><title>首页促销区</title></block>
<block name="style">
 <style>
.main,.panel-default>.panel-heading{
background:none;
}
body{
background:none;
}
.panel.panel-default,.panel .panel-body,.panel .panel-heading,.table-bordered {
	border:none;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
	border:none;		
	padding:15px;	
	line-height:8px;
	height: 8px;
	border-top: 1px solid #d4d4d4;
	border-bottom: 1px solid #d4d4d4;
}
.name strong{
color:#000000;
font-size:15px;
font-weight:600;
}
.name {
	color:#20a8d8;
	font-size:12px;
}
.smallfont {
	color:#9c9c9c;
	font-size:12px;
}

.align-center{
	text-align:center; 
}
.title2{
text-align:center;
}
.table-bordered > tbody > tr .wd{
	text-align:left;	
}
.col-md-2{
width:14%;
}
.col-xs-2,.col-xs-4{
padding-right:0;
margin:10px 0;
}
.col-sm-3{
width:10%;
}
.col-sm-2{
width:8%;
}
.col-sm-1{
width:5%;
}
.col-sm-4{
width:18%;
}
.col-sm-1,.col-sm-2{
margin:16px 0;
}
.col-sm-3,.col-sm-4{
margin:10px 0;
}
.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4{
padding-right:0;
}
 </style>
</block>
	<!-- start: Header -->
<block name="body">

			<!-- end: Main Menu -->
						
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-life-bouy"></i>首页促销区</h3>
				</div>
			</div>

			<div class="row">
				<div class="col-md-12">
			        <div class="panel panel-default">
						<div class="panel-heading">
							
							<a class="btn btn-default " href="{:U('Index/home_sales')}" >促销区</i></a>&nbsp;&nbsp;&nbsp;
							<h2><span class="break"></span><strong>新增促销区</strong></h2>							
						</div>&nbsp;&nbsp;&nbsp;
						<div class="panel-body" style="width: 60%;">
							 <div class="form-group">
				                    <label class="col-md-3 control-label" for="email-input">&nbsp;</label>
									<span class="help-block">修改该区域中部推荐商品促销区名称，控制名称字符在4-8字左右，超出范围自动隐藏</span>
				             </div>
							<form action="{:U('Index/sales_add')}" method="post" id="form" class="form-horizontal ">
							<input type="hidden"  name="select" class="form-control" value="1">
							<input type="hidden"  name="se_id" class="form-control" value="{$prom_one.se_id}">
							<input type="hidden"  name="type" class="form-control" value="{$type}">							
							
				                <div class="form-group">
				                    <label class="col-md-3 control-label" for="text-input"><font style="color:red;">*</font>&nbsp;&nbsp;促销区名称：</label>
				                    <div class="col-md-9">
				                        <input type="text" id="se_name" name="se_name" class="form-control" value="{$prom_one.se_name}">
				                        <span class="help-block"></span>
				                    </div>
				                </div>
				                <div class="form-group">
				                    <label class="col-md-3 control-label" for="text-input">&nbsp;&nbsp;是否推荐：</label>
				                    <div class="col-md-9">
				                        <input type="text" id="se_goin" name="se_goin" class="form-control" value="{$prom_one.se_goin}">
				                        <span class="help-block">只能推荐一个，当本次推荐时，其他添加不可再推荐，1为推荐，0为不推荐，默认为不推荐</span>
				                    </div>
				                </div>
				                <div class="form-group">
				                    <label class="col-md-3 control-label" for="email-input">被选中商品：</label>
				                    <div  id="goods_goin">
										<if condition="$prom_one.goods neq ''">
										<foreach name="prom_one.goods" item="vo">
										<div class="col-md-2">
											<img class="img-thumbnail" src="{$vo.pic}">
											<span> {$vo.productname}</span>
											<input type="hidden"  name="g_id[]" value="{$vo.id}">
											
											<a href="javascript:;" style="color:red; " data-type="del">移除</a>
										</div>
										</foreach>
										
										<else/>
										<div class="col-md-2">
											<img class="img-thumbnail" src="__PUBLIC__/Home/images/default_goods_image_240.gif" >
										 </div>
										</if>
				                    </div>
									
				                </div>
							
							</form>	
							<br/>
							 <div class="form-group">
				                    <label class="col-md-3 control-label" for="email-input">&nbsp;</label>
									<span class="help-block" style="color:red;">请搜索需要添加的商品</span>
				             </div>
							<form action="{:U('Index/home_sales')}?id={$prom_one.se_id}" method="get" class="form-horizontal ">
							<input type="hidden"  name="select" class="form-control" value="1">
							<input type="hidden"  name="id" class="form-control" value="{$prom_one.se_id}">
				                <div class="form-group">
				                    <label class="col-md-3 control-label" for="email-input" style="color:#03a9f4;">搜索&nbsp;店铺名称:</label>
				                    <div class="col-md-9">
				                       <input type="text" id="adv_title" name="store_name" class="form-control" value="">
				                        <span class="help-block"></span>
				                    </div>
				                </div>							

				                <div class="form-group">
				                    <label class="col-md-3 control-label" for="password-input" style="color:#03a9f4;">搜索&nbsp;商品名称:</label>
				                    <div class="col-md-7">
				                        <input type="text" id="commis_rate" name="goods_name" class="form-control" value="">
									</div>
				                        <span class="help-block"><span style="color:red;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
										<button type="submit" class="btn btn-sm btn-primary">搜索</button>
										</span>
				                    
				                </div>
				                <div class="form-group">
				                    <label class="col-md-3 control-label" for="email-input" style="color:#03a9f4;">请选择商品：</label>
										<foreach name="g_list" item="vo">
										 <div class="col-md-2">
											<a href="javascript:;" data-gid="{$vo.id}" data-type="goods">
											<img class="img-thumbnail" src="{$vo.pic}"  >
											<span>{$vo.productname}</span>
											</a>
										 </div>										 
										 </foreach>									
				                </div>									
							</form>	
						

								<br>
				            
						</div>
						<div class="panel-footer" style="border:none">
						
		                    <a href="javascript:;" class="btn btn-bg btn-success" id="submit"><i class="fa fa-dot-circle-o"></i> 保存</a>
						
	                       
		                </div>
										
			        </div>	
			    </div>			

			
			</div><!--/row-->				
			
		<!-- end: Content -->
		<br><br><br>
		
	</div><!--/container-->
	
</block>
<block name="script">
<script>
	 
	$("[data-type='goods']").click(function(){
		var vals = $(this).attr("data-gid") ;
		var src = $(this).find("img").attr('src'); 
		var name = $(this).find("span").html();
		var html = '<div class="col-md-2"><img class="img-thumbnail" src="'+src+'"><span> '+name+'</span><input type="hidden"  name="g_id[]" value="'+vals+'">&nbsp;<a href="javascript:;" style="color:red; " data-type="del">移除</a></div>' ;
		var xml = $('#goods_goin').children().find('span').html();
		
		
		if (xml) {
			var xml = $('#goods_goin').html();
			var num = $('#goods_goin').children().length ;
			//alert(num);
			if (num<5) {
				$('#goods_goin').html(xml+html);
			}
			
		} else {
			$('#goods_goin').html(html);
		}
		
	});

	$("[data-type='del']").on('click',function(){
		var xml = $(this).parent().remove();
		//alert(xml);
	});
	//提交表单
	$("#submit").on('click',function(){
			$("#form").submit();
	});
	
</script>
</block>	









